package com.springcloud.feigndemo.controller

import com.springcloud.feigndemo.Service.FeignService
import com.springcloud.feigndemo.pojo.MyMultipartFile
import com.springcloud.feigndemo.pojo.User
import com.springcloud.feigndemo.pojo.Word
import io.swagger.annotations.ApiParam
import org.apache.commons.fileupload.FileItem
import org.apache.commons.fileupload.disk.DiskFileItem
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.core.io.FileSystemResource
import org.springframework.core.io.Resource
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import org.springframework.web.multipart.MultipartFile
import org.springframework.web.multipart.commons.CommonsMultipartFile


@RestController
class MyController {

    @Autowired
    FeignService service

    @Autowired
    User user

    @RequestMapping(value = '/query',method = RequestMethod.GET)
    ResponseEntity query(@RequestParam @ApiParam(name = "wd",required = true) String wd)
    {
        println(user.name+'   '+user.info)

        service.q(new Word(wd),user.name,user.info)
    }

    @RequestMapping(value = 'file',method = RequestMethod.POST)
    String file()
    {
        service.file(new MyMultipartFile('file',MediaType.IMAGE_JPEG,new File('C:\\Users\\逆游的鱼\\Desktop\\tmp\\pic\\xie.jpg')))
    }

    @RequestMapping(value = 'img',method = RequestMethod.GET)
    ResponseEntity<Resource > img(){
        service.image()
    }

}
